package com.zhbcm.outupload.common.exception;

import com.zhbcm.outupload.common.response.ApiResult;
import com.zhbcm.outupload.common.response.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: 朝花不迟暮
 * @Date: 2021/12/23 22:36
 * @Description:
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 接口错误统一处理
     *
     * @param e 异常
     * @return 返回结果
     */
    @ExceptionHandler(value = ApiException.class)
    @ResponseBody
    public ApiResult jsonErrorHandler(ApiException e) {
        return ResultUtil.errMsg(e.getMessage());
    }
}